#include<iostream>
#include<fstream>
#include<cstdlib>

using namespace std;

int main()
{
    ifstream infile;
    infile.open("test.txt");
    if ( !infile.is_open())
    {
        exit(EXIT_FAILURE);
    }
    char ch;
    int count = 0;
    infile >> ch;
    while ( infile.good())
    {
        count++;
        infile >> ch;
    }
    if ( infile.eof())
    {
        cout << "File terminate becase of reaching EOF.\n";
    }
    else if ( infile.fail())
    {
        cout << "File terminater by the file fail.\n";
    }
    else
    {
        cout << "No reason.\n";
    }
    cout << "The file test.txt has " << count << " character." << endl;
    infile.close();

    return 0;
}